package com.feidee.fd.sml.algorithm.feature

import com.feidee.fd.sml.algorithm.component.feature.{NGramEncoder, NGramEncoderParam}
import com.feidee.fd.sml.algorithm.util.{TestingDataGenerator, ToolClass}
import org.scalatest.FunSuite

/**
  * @Author JunxinWang
  * @Date 2019/3/26 19:05
  * @Description
  * @Reviewer YongChen
  */
class NGramEncoderSuite extends FunSuite {

  val ngram = new NGramEncoder()
  val paramStr: String =
    """
      |{
      | "inputCol": "feature"
      |}
    """.stripMargin
  val param: NGramEncoderParam = ngram.parseParam(new ToolClass().encrypt(paramStr))

  test("ngram parameter construction test") {
    assert(param.input_pt == null && param.output_pt == null && param.modelPath == null &&
      "feature".equals(param.inputCol)
    && param.n==2
    )

  }

  test("ngram transforming function test") {
    import TestingDataGenerator.spark.implicits._
    val rawData = Seq(Array("asdas", "asd", "asda", "s"), Array("asdasda","as", "das", "d")).toDF("feature")

    val ngramData = ngram.train(param, rawData).transform(rawData)
    ngramData.show(false)
  }
  }